package howe.sudoku.db;

import android.content.Context;

public class DAOFactory {
    private static DAOFactory instance = null;

    private Context globalContext = null;

    public static DAOFactory getInstance() {
        if (instance == null) {
            instance = new DAOFactory();
        }
        return instance;
    }

    private DAOFactory() { }

    public SudokuDao getSudokuDao(Context context) {
        return new SudokuDao(getProperDAOContext(context));
    }

    public void setGlobalContext(Context context) {
        globalContext = context;
    }

    private Context getProperDAOContext(Context context) {
        if (globalContext != null) {
            return globalContext;
        } else {
            return context;
        }
    }
}
